package com.android.wake_up_enable_hotspot;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class SpUtil {
    public static final String KEY_ENABLE = "key_enable";
    private static final String KEY_LAST_MAC = "last_mac";
    private static final String KEY_LAST_SSID = "last_ssid";

    public static boolean isFeaturesEnable(Context context) {
        return getSp(context).getBoolean(KEY_ENABLE, false);
    }

    public static void setFeaturesEnable(Context context, boolean enable) {
        getSp(context).edit().putBoolean(KEY_ENABLE, enable).apply();
    }

    public static String getSavedBtName(Context context) {
        return getSp(context).getString(KEY_LAST_SSID, "");
    }

    public static String getSavedBtMac(Context context) {
        return getSp(context).getString(KEY_LAST_MAC, "");
    }

    public static void saveBtInfo(Context context, String btName, String btMac) {
        getSp(context).edit().putString(KEY_LAST_SSID, btName).putString(KEY_LAST_MAC, btMac).apply();
    }

    public static SharedPreferences getSp(Context context) {
        return context.getSharedPreferences(PreferenceManager.getDefaultSharedPreferencesName(context), 0);
    }
}